<?php

/*
 * Action 1$
 * 
 * +4 Coin
 * Reveal your hand. -1 Coin per Treasure card in your hand, to a minimum of 0 Coin.
 */

class PoorHouse extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Poor House", 1);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+4$",
            "Reveal your hand. -1 Coin per Treasure card in your hand, to a minimum of 0 Coin.");
    }

    public function play(Game $game, $isRealCard) {
        $playHand = $game->getPlayHand();
        ScreenDisplay::addScreenMessage($game, true, "reveal  " . nicePrint($playHand), "reveals " . ScreenDisplay::$LMSG);

        $treasures = 0;
        $player_coins = $game->getMoney()->getCoins();
        $coins = 4;

        foreach ($playHand as $card) {
            if ($card instanceof iTreasure) {
                $coins -=1;
            }
            if ($coins == -$player_coins) {
                break;
            }
        }

        $game->addMoney(new Price($coins));
        ScreenDisplay::addScreenMessage($game, false, " and get $coins$ ", " and gets $coins$ ");
        $game->cardActionFinished();
        return true;
    }

}

?>